package cn.hanyx.coder.design.pattern.creational.singleton;

import java.util.concurrent.atomic.AtomicLong;

/**
 * IdEnum01
 *
 * @author hanyx
 * @date 2020/07/14
 */
public enum IdEnum01 implements ICall {
    INSTANCE;

    private AtomicLong id = new AtomicLong(0);

    public long getId() {
        call();
        return id.incrementAndGet();
    }

    public static void main(String[] args) {
        System.out.println(IdEnum01.INSTANCE.getId());
        ;
    }

    @Override
    public void call() {
        System.out.println("call");
    }
}
